/*
 * @Author: hucc
 * @Date: 2021-09-28 09:30:56
 * @LastEditors: hucc
 * @LastEditTime: 2021-09-28 15:36:07
 * @Description: 
 */
class Animal {
    //静态属性
    static animalAttr = "Animal静态属性";
    //实例属性
    constructor(name, age) {
            this.name = name;
            this.age = age;
        }
        //实例方法
    animalFun() {
            console.log("Animal实例方法")
        }
        //静态方法
    static animalStaFun() {
        console.log("Animal静态方法");
    }
}
class Dog extends Animal {
    constructor(name, age, color, weight) {
        //super() 继承父类构造函数的属性和方法
        super(name, age);
        this.color = color;
        this.weight = weight;
    }
}
//继承了Animal的实例属性和实例方法
let dog = new Dog("二狗", 1, "black", "10kg");
console.log(dog); //Dog { name: '二狗', age: 1, color: 'black', weight: '10kg' }
dog.animalFun(); //Animal实例方法
//测试原型链继承
console.log(Dog.prototype.__proto__ === Animal.prototype); //true
console.log(dog.__proto__.__proto__ === Animal.prototype); //true
//继承了Animal的静态属性和静态方法 用类来继承
console.log(Dog.animalAttr); //Animal静态属性
Dog.animalStaFun(); //Animal静态方法
//测试构造函数的继承
console.log(Dog.__proto__ === Animal); //true